package com.dragon.repository.domain.dto;

import com.baomidou.mybatisplus.annotation.TableField;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.OtherFile;
import com.dragon.repository.entity.Produce;
import com.dragon.repository.entity.ProduceProducts;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ProduceDTO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "合同id")
    private Integer contractId;

    @ApiModelProperty(value = "用户id")
    private Integer adminId;

    @ApiModelProperty(value = "部门id")
    private Integer departmentId;

    @ApiModelProperty(value = "生产单号")
    private String number;

    @ApiModelProperty(value = "生产的名称")
    private String name;

    @ApiModelProperty(value = "生产数量")
    private Long quantity;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date updateTime;

    @ApiModelProperty(value = "生产截至时间")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date endTime;

    @ApiModelProperty(value = "交货时间")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date deliveryTime;

    @ApiModelProperty(value = "生产状态：0.待生产1.生产中2.生产完成")
    private Integer type;

    @ApiModelProperty(value = "审核状态：0待审核 1审核通过 2审核不通过 3作废 4删除")
    private Integer status;

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "负责人id")
    private Integer responsibleId;

    @ApiModelProperty(value = "项目名称")
    private String contractName;

    @ApiModelProperty(value = "负责人名称")
    private String responsibleName;

    @ApiModelProperty(value = "申请人名称")
    private String applicantName;

    @ApiModelProperty(value = "附件")
    private List<OtherFile> otherFileList;

    @ApiModelProperty(value = "合同地址")
    private String contractAddress;

    @ApiModelProperty(value = "客户id")
    private Integer customerId;

    @ApiModelProperty(value = "生产产品信息")
    private List<ProduceProducts> produceProducts;

    @ApiModelProperty(value = "客户名称")
    private String customerName;

    @ApiModelProperty(value = "收货状态")
    private Integer deliverStatus;

    @ApiModelProperty(value = "0生产单 1生产单(重做) 2生产单维修")
    private Integer source;

    @ApiModelProperty(value = "排产状态 0未排产 1部分排产 2排产完成")
    public Integer schedulingStatus;

    @ApiModelProperty(value = "退货单id")
    private Integer rejectedId;

    @ApiModelProperty(value = "完成状态 0未完成，1部分完成 2全部完成")
    private Integer finishedStatus;

    @ApiModelProperty(value = "签订时间")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date orderTime;

    @ApiModelProperty(value = "合同编码")
    private String contractCode;


    public ProduceDTO() {}

    public ProduceDTO(Produce entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static ProduceDTO convert(Produce entity) {
        return new ProduceDTO(entity);
    }

    public static List<ProduceDTO> convertList(List<Produce> list) {
        List<ProduceDTO> resultList = new ArrayList<>();
        for (Produce entity : list) {
            resultList.add(new ProduceDTO(entity));
        }
        return resultList;
    }}
